package com.tfy.liquor.controller.thymeleaf;

import com.tfy.liquor.bean.ProductInfo;
import com.tfy.liquor.service.ProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * thymeleaf路由控制器
 */
@Controller
public class routerController {
    @Autowired
    private ProductInfoService productInfoService;

    @RequestMapping("/")
    public String indexFreeMarker() {
        // 写入数据
//        ModelAndView modelAndView = new ModelAndView("index");
//        modelAndView.addObject("list", list);
        return "PC/login";
    }

    //    进入首页
    @RequestMapping("/manage-index")
    public String index() {
        return "PC/index";
    }

    // 流水记录
    @RequestMapping("/userPriseRecordsInfo")
    public String userPriseRecordsInfo() {
        return "PC/userPriseRecordsInfo";
    }

    // 供应商信息
    @RequestMapping("/vendorInfo")
    public String vendorInfo() {
        return "PC/vendorInfo";
    }

    // 类别管理
    @RequestMapping("/categoryInfo")
    public String categoryInfo() {
        return "PC/categoryInfo";
    }

    // 产品管理
    @RequestMapping("/productInfo")
    public String productInfo() {
        return "PC/productInfo";
    }

    // 添加产品
    @RequestMapping("/addProductInfo")
    public String addProductInfo() {
        return "PC/addProductInfo";
    }

    // 编辑产品，需要原始的产品数据
    @RequestMapping("/editProductInfo")
    public String editProductInfo(Model model, String id) {
        ProductInfo productInfo = productInfoService.getProductInfoByProductId(id);
        model.addAttribute("productInfo", productInfo);
        return "PC/editProductInfo";
    }

    // 系统配置信息
    @RequestMapping("/systemConfigurationInfo")
    public String systemConfigurationInfo() {
        return "PC/systemConfigurationInfo";
    }


    /**
     * test测试页面
     *
     * @return
     */
    @RequestMapping("/test")
    public String test() {
        return "PC/test";
    }
}
